var app = getApp()

Page({
	data: {
		resdata: {},
		id: '',
		type: app.globalData.userType
	},
	onLoad: function (option) {
		// 接收路由参数，发送页面请求init
		console.log(option)
		const item = JSON.parse(option.item)
		console.log('item---', item)
		this.setData({
			id: item.id,
			type: app.globalData.userType
		})
		// app.getUrl(this), app.getSystem(this);
		wx.setNavigationBarTitle({
			title: option.date
		})
		// wx.setNavigationBarColor({ // 不调用接口，通过json配置
		//   frontColor: "#f00",
		//   backgroundColor: '#0f0'
		// })
		this.init()
	},
	init() {
		const flag = app.globalData.userType
		console.log(flag)
		if (flag == 2) {
			wx.request({
				url: app.siteInfo.siteroot_web,
				cachetime: '0',
				method: 'GET',
				data: {
					c: 'statistics',
					a: 'receptionlist',
					user_id: app.globalData.userId,
					statistics_id: this.data.id
				},
				success: resp => {
					const res = resp.data
					console.log('res--', res)
					if (res.code == 0) {
						// 请求成功
						this.setData({
							resdata: res.data.data
						})
					} else {
						// 请求失败
						wx.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				}
			})
		} else {
			wx.request({
				url: app.siteInfo.siteroot_web,
				cachetime: '0',
				method: 'GET',
				data: {
					c: 'statistics',
					a: 'salesmanMoneyList',
					user_id: app.globalData.userId,
					statistics_id: this.data.id
				},
				success: resp => {
					const res = resp.data
					console.log('res--', res)
					if (res.code == 0) {
						// 请求成功
						this.setData({
							resdata: res.data.data
						})
					} else {
						// 请求失败
						wx.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				}
			})
		}
	},
	tel: function (n) {
		var o = wx.getStorageSync('platform').tel
		wx.makePhoneCall({
			phoneNumber: o
		})
	},
	gotosetting() {
		wx.showToast({
			title: '设置页面'
		})
	},
	togodetail() {
		wx.navigateTo({
			url: '/zh_jdgjb/pages/salerecorddetail/salerecorddetail'
		})
	},
	onReady: function () {},
	onShow: function () {},
	onHide: function () {},
	onUnload: function () {},
	onPullDownRefresh: function () {},
	onReachBottom: function () {}
})
